package framework.objects.bullets;

import android.graphics.Rect;
import framework.objects.DynamicGameObject;
import framework.objects.Hitable;

public abstract class Bullet extends DynamicGameObject {

	protected float dy;
	protected float dx;

	public Bullet(float x0, float y0, float dx, float dy, float kV) {
		super();
		this.x = x0;
		this.y = y0;
		this.x0 = x0;
		this.y0 = y0;
		this.dx = dx;
		this.dy = dy;
		this.kV = kV;
	}

	protected float x0;
	protected float y0;
	protected float kV;
	
	public void tryToHit(Hitable object) {
		if (Rect.intersects(this.getRect(), ((DynamicGameObject)object).getRect())) {
			object.onHit(this);
		}
	}
	
	public abstract void onHit();
	
	@Override
	public Rect getRect() {
		return new Rect((int)x - 1, (int)y - 1, (int)x + 1, (int)y + 1);
	}
	
}
